<template>
	<view class="main-page">
		<view class="name-box">
			<text class="font-999-28">团员名称</text>
			<text class="font-333-32 font-weight-600">{{memberName}}</text>
		</view>
		
		<view class="content-box">
			<view class="row-container-row-between width-100p" v-if="dataList.length > 0">
				<text class="font-999-26">时间</text>
				<text class="font-999-26">金额</text>
			</view>
			<view class="row-container-row-between width-100p mt-30" 
			v-for="(item , index) in dataList" :key="index" v-if="dataList.length > 0">
				<text class="font-333-30">{{item.createTime}}</text>
				<text class="font-333-30 font-weight-600">+{{item.integral}}元</text>
			</view>
			
			<view class="column-container-center width-100p mt-100 mb-150" v-if="dataList.length < 1">
				<image src="../../static/ic_empty.png" class="wh-70 mb-30"></image>
				<text class="font-333-36 font-weight-600" >暂无数据</text>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				memberId:'',
				memberName:'' , 
				dataList:[],
				pageNo:1,
				hasMoreData:false
			}
		},
		
		onLoad(options) {
			this.memberId = options.memberId
			this.memberName = options.memberName
			this.loadData()
		},
		
		onPullDownRefresh() {
			this.pageNo = 1
			this.loadData()
		},
		
		onReachBottom() {
			if (this.hasMoreData){
				this.pageNo ++ 
				this.loadData()
			}
		},
		
		methods: {
			loadData(){
				let that = this
				this.http({
					url:'/user/gxList',
					method:'POST',
					data:{
						pageNo : that.pageNo,
						pageSize : 20,
						uid : that.memberId
					},
					success(res){
						if (res.code == 200){
							if (that.pageNo == 1){
								that.dataList = res.data
							} else{
								that.dataList = [...that.dataList, ...res.data]
							}
							that.hasMoreData = res.data.length >= 20
						}
						uni.stopPullDownRefresh()
					},
					failed(e){
						uni.stopPullDownRefresh()
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.name-box{
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		width: calc(100% - 56rpx);
		height: 90rpx;
		background: white;
		margin: 20rpx 0rpx;
		padding: 0rpx 28rpx;
	}
	
	.content-box{
		display: flex;
		flex-direction: column;
		align-items: center;
		width: calc(100% - 56rpx);
		padding: 30rpx 28rpx;
		background: white;
	}
</style>
